
INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} ${IPP_INCLUDE_DIR} ${FW_INCLUDE_DIR})

SET(CPP_FILES DoScanAtCPU DoCalSARAtCPU)

foreach(CPP_FILE ${CPP_FILES})
    SET(CPP_FILE_NAME ${CPP_FILE}.cpp)
    add_library(${CPP_FILE} SHARED ${CPP_FILE_NAME} ${CMAKE_SOURCE_DIR}/Matlabdef.def)
    target_link_libraries(${CPP_FILE} ${MATLAB_LIBRARIES} ${IPP_LIBRARIES} ${FW_LIBRARIES})

    if(WIN32)
      if (CMAKE_CL_64)
          SET_TARGET_PROPERTIES(${CPP_FILE} PROPERTIES SUFFIX .mexw64 COMPILE_FLAGS ${OpenMP_CXX_FLAGS} LINK_FLAGS ${OpenMP_CXX_FLAGS})
      else(CMAKE_CL_64)
          SET_TARGET_PROPERTIES(${CPP_FILE} PROPERTIES SUFFIX .mexw32 COMPILE_FLAGS ${OpenMP_CXX_FLAGS} LINK_FLAGS ${OpenMP_CXX_FLAGS})
      endif(CMAKE_CL_64)
    else(WIN32)
      if (CMAKE_SIZEOF_VOID_P MATCHES "8")
          SET_TARGET_PROPERTIES(${CPP_FILE} PROPERTIES SUFFIX .mexa64 PREFIX "" COMPILE_FLAGS ${OpenMP_CXX_FLAGS} LINK_FLAGS ${OpenMP_CXX_FLAGS})
      else(CMAKE_SIZEOF_VOID_P MATCHES "8")
          SET_TARGET_PROPERTIES(${CPP_FILE} PROPERTIES SUFFIX .mexglx PREFIX "" COMPILE_FLAGS ${OpenMP_CXX_FLAGS} LINK_FLAGS ${OpenMP_CXX_FLAGS})
      endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
    endif(WIN32)

    install(TARGETS ${CPP_FILE} DESTINATION ../bin)
endforeach(CPP_FILE ${CPP_FILES})